<%-- 
    Document   : videogames
    Created on : 23-mag-2013, 16.38.08
    Author     : Luca
--%>

<%@page import="ejb.ArticoloUsato"%>
<%@page import="ejb.RecensioneEsterna"%>
<%@page import="java.util.List"%>
<%@page import="ejb.Utente"%>
<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="wrapper.jsp" %>
<style type="text/css">
.aggiungi {
width: 85px;
float: left;
padding-top: 5px;
text-align: right;
}
</style>
<%
    Utente utSession = (Utente)session.getAttribute("utente");
    String tipo = utSession.getTipo();
%>

<div class="container">
   <div class="row-fluid">
        <div class="span3 bs-docs-sidebar">
            <ul class="nav nav-list bs-docs-sidenav">
                 <% if(tipo.equals("a")){%>
                <li><a href="Controller?button=visualizzaRecensori"> 
                <button class="btn btn-large btn-inverse btn-block" style="width:210px"><i class="icon-white icon-th-list"></i> Tutti i Recensori</button> </a></li>
                <li><a href="Controller?button=aggiungiRecensoreAus"> 
                <button class="btn btn-large btn-inverse btn-block" style="width:210px"><i class="icon-white icon-plus"></i> Aggiungi Recensore</button> </a></li>
                <%}%>
                <% if(tipo.equals("r")){%>
                <li><a href="Controller?button=aggiungiRecensioneInternaAus"> 
                <button class="btn btn-large btn-inverse btn-block" style="width:210px"><i class="icon-white icon-plus"></i> Aggiungi Rec. Interna</button> </a></li>
                <li><a href="Controller?button=aggiungiRecensioneEsternaAus"> 
                <button class="btn btn-large btn-inverse btn-block" style="width:210px"><i class="icon-white icon-plus"></i> Aggiungi Rec. Esterna</button> </a></li>
                <%}%>
                <li><a href="Controller?button=visualizzaRecensioniInterne"> 
                <button class="btn btn-large btn-inverse btn-block" style="width:210px"><i class="icon-white icon-th-list"></i> Recensioni Interne</button> </a></li>
                <li><a href="Controller?button=visualizzaRecensioniEsterne"> 
                <button class="btn btn-large btn-inverse btn-block" style="width:210px"><i class="icon-white icon-th-list"></i> Recensioni Esterne</button> </a></li>
            </ul>
        </div>   

<div class="span6">   
    <div class="thumbnail">   
    <h3>Elenco Recensioni Esterne</h3>
    
 <form action="Controller" method="POST">
     <table class="table table-hover">
    <%
    List<RecensioneEsterna> recensioni= (List<RecensioneEsterna>)request.getAttribute("recensioniEsterne");
    List<ArticoloUsato> usatiDaConfermare= (List<ArticoloUsato>)session.getAttribute("usatiDaConfermare");
    String u=((Utente)(session.getAttribute("utente"))).getUsername();
    if(!recensioni.isEmpty()){
        int i=0;
        for(RecensioneEsterna n:recensioni){  
        %>
        <tr>
              <% if(u.equals(n.getAutore().getUsername()) || tipo.equals("a")){
              i++;%>
              <td style="width:220px"><%=n.getUrl()%></td> 
              <td><a href="Controller?button=preparaModificaRecEsterna&id=<%=n.getId()%>"><button class="btn btn-inverse btn-small" type="button"><i class="icon-white icon-wrench"></i> Modifica</button>  </a> </td> 
              <td><a href="Controller?button=cancellaRecensioneEsterna&id=<%=n.getId()%>"><button class="btn btn-inverse btn-small" type="button"><i class="icon-white icon-trash"></i> Cancella</button>  </a> </td> 
              <%}%>
     </tr>
     <%}
       if(i==0){%>
       <tr>
            <td>Nessuna recensione interna visualizzabile.</td> 
       </tr>
       <%}
    }else {%>
     <tr>
       <td>Nessuna recensione esterna presente.</td> 
     </tr>
    <%}%>
     </table>
 </form>
</div>
</div>    
<div class="span3">
    <% if(tipo.equals("a")){%>
    <div class="thumbnail">
                 <p><b>Notes</b></p>
                 <br>
                 <% if(!usatiDaConfermare.isEmpty()){%>
                    <p> Ancora <%=usatiDaConfermare.size()%> articoli da confermare </p>
                    <br>
                    <p align="center">
                        <a href="Controller?button=modificaCancellaArtUsati&amp;confirm=s">
                            <button class="btn btn-inverse btn-small"><i class="icon-white icon-th-list"></i> Vedi Articoli da confermare</button>
                        </a>
                    </p>
                 <%}else{%>
                 <p> Nessun articolo da confermare </p>
                <%}%>      
            </div>
      <%}%>   
      </div>          
   </div>
</div>
</body>